﻿using System;
using System.Globalization;

namespace WeekDayServiceREST
{
    public class WeekDayRestService : IServiceWeekDayRestService
    {
        public string GetWeekDay(string dateAsString)
        {
            string[] formats = { "dd-mm-yyyy", "d-m-yyyy"};
            DateTime dateValue;
            DateTime.TryParseExact(dateAsString, formats,
                                       new CultureInfo("en-US"),
                                       DateTimeStyles.None,
                                       out dateValue);            

            switch (dateValue.DayOfWeek)
            {
                case DayOfWeek.Friday:
                    return "Petak";
                case DayOfWeek.Monday:
                    return "Ponedelnik";
                case DayOfWeek.Saturday:
                    return "Subota";
                case DayOfWeek.Sunday:
                    return "Nedelq";
                case DayOfWeek.Thursday:
                    return "Chetvartak";
                case DayOfWeek.Tuesday:
                    return "Vtornik";
                case DayOfWeek.Wednesday:
                    return "Srqda";      
                default:
                    throw new ApplicationException();
            }
        }
    }
}
